package StaticToolTest;

use strict;

my $test_dir = "tests/";

sub gccTest {
	my $test = shift;
	my $tool = "gcc";
	my $log = createLogName($test, $tool);
	#system ("$tool -c -trigraphs -fstrict-aliasing -fstrict-overflow -Wall -o /dev/null $test_dir$test.c > $log 2>&1");
	system ("i686-pc-linux-gnu-$tool -c -trigraphs -fstrict-aliasing -fstrict-overflow -Wall -Wstrict-overflow=4 -o /dev/null $test_dir$test.c > $log 2>&1");
}	

sub clangTest {
	my $test = shift;
	my $tool = "clang";
	my $log = createLogName($test, $tool);
	#system ("$tool -c -Wall -o /dev/null $test_dir$test.c > $log 2>&1");
	#system ("echo /*----------Analyzer----------*/ >> $log");
	system ("$tool --analyze -o /dev/null $test_dir$test.c > $log 2>&1");
}	



sub splintTest {
	my $test = shift;
	my $tool = "splint";
	my $log = createLogName($test, $tool);
	system ("$tool -retvalother +quiet $test_dir$test.c > $log 2>&1");
}	

sub cppcheckTest {
	my $test = shift;
	my $tool = "cppcheck";
	my $log = createLogName($test, $tool);
	system ("$tool -q --enable=all $test_dir$test.c > $log 2>&1");
}	

sub createLogName {
	my $test = shift;
	my $tool = shift;
	my $log = "logs/$tool" . "log/$test";

	unless ( -e "logs" ){
		mkdir "logs";
	}
	unless ( -e "logs/$tool" . "log") {
		mkdir "logs/$tool" . "log";;
	}
	return $log;
}

1;
